<?php
    require_once('../includes/DbConnector.php');
    
    if(isset($_GET['action']) && !empty($_GET['action'])) {
        // INPUT DATA.
        $action = $_GET['action'];
        $barid = $_GET['barid'];
        $connector  = new DbConnector();
        $sql = "select
                avg(rating) rating
                from user_bar
                where bar_id= '$barid'";
        $result = $connector->query($sql);
        
        $a = mysql_fetch_assoc($result);
        
        echo json_encode($a);
    }
?>